package com.lc.soft.controller;

import com.lc.soft.entity.CommonParameter;
import com.lc.soft.entity.MapEntity;
import com.lc.soft.service.IMapService;
import com.lc.soft.utils.ResponseResult;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("map")
@Log4j2
public class MapController {

    private IMapService mapService;

    @Autowired
    public MapController(IMapService mapService) {
        this.mapService = mapService;
    }

    @RequestMapping("create")
    public ResponseResult create(MapEntity mapEntity) {
        Long start = new Date().getTime();
        ResponseResult responseResult = mapService.create(mapEntity);
        Long end = new Date().getTime();
        log.info("间隔时间：" + (end - start) + "ms");
        return responseResult;
    }

    @RequestMapping("update")
    public ResponseResult updateMap(MapEntity mapEntity) {
        Long start = new Date().getTime();
        ResponseResult responseResult = mapService.update(mapEntity);
        Long end = new Date().getTime();
        log.info("间隔时间：" + (end - start) + "ms");
        return responseResult;
    }

    @RequestMapping("updateState")
    public ResponseResult updateState(MapEntity mapEntity) {
        Long start = new Date().getTime();
        ResponseResult responseResult = mapService.updateState(mapEntity);
        Long end = new Date().getTime();
        log.info("间隔时间：" + (end - start) + "ms");
        return responseResult;
    }

    @RequestMapping("findPagedMapListByCondition")
    public ResponseResult findPagedMapListByCondition(CommonParameter commonParameter) {
        Long start = new Date().getTime();
        ResponseResult responseResult = mapService.findPagedMapListByCondition(commonParameter);
        Long end = new Date().getTime();
        log.info("间隔时间：" + (end - start) + "ms");
        return responseResult;
    }
}
